<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>登录</title>
  <link rel="stylesheet" href="__INDEX__/jigsaw/jigsaw.css">
  <style>
    .container {
      width: 310px;
      margin: 100px auto;
    }
    input {
      display: block;
      width: 290px;
      line-height: 40px;
      margin: 10px 0;
      padding: 0 10px;
      outline: none;
      border:1px solid #c8cccf;
      border-radius: 4px;
      color:#6a6f77;
    }
    #msg {
      width: 100%;
      line-height: 40px;
      font-size: 14px;
      text-align: center;
    }
    a:link,a:visited,a:hover,a:active {
      margin-left: 100px;
      color: #0366D6;
    }

  </style>
</head>
<body>
<div class="container">
  <input id="user" type="text" placeholder="请输入账号" />
  <input id="pwd" type="password" placeholder="请输入密码"/>
  <input id="captcha" type="text" placeholder="请输入验证码"/>

  <div><img src="{:captcha_src()}" id="index" alt="captcha" width="300px"/></div>
  <div>
    <button id="submit">提交</button>
  </div>
</div>
<script src="__INDEX__/js/jquery.3.3.1.min.js"></script>
<script src="__INDEX__/mui/js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__INDEX__/mui/js/mui.view.js" type="text/javascript" charset="utf-8"></script>
<!--<script src="http://static.geetest.com/static/tools/gt.js"></script>-->
<script>
//  console.log('haha1');
  $("#index").on('tap',function () {
      console.log('haha');
      $(this).attr('src',"{:captcha_src()}?"+Math.random());
  });
  $("#submit").on('tap',function () {
      var $user = $("#user").val();
      var $pwd  = $("#pwd").val();
      var $captcha = $("#captcha").val();
      if(!$captcha||$captcha==' '){
          alert('请输入验证码');
          return;
      }
      if(!$user||$user==' '){
          alert('请输入账号');
          return;
      }
      if(!$pwd||$pwd==' '){
          alert('请输入密码');
          return;
      }
      $.post("{:url('login/index')}",{user:$user,pwd:$pwd,captcha:$captcha},function (data) {
          console.log(data);
          if(data.code==200){
//              alert(data.msg);
              window.location.href = "{:url('index/index')}";
          }else{
              $("#index").attr('src',"{:captcha_src()}?"+Math.random());
              alert(data.msg);
          }
      });
  });
</script>
</body>
</html>
